package openbang.chatroom.web.client;

import java.util.List;

import openbang.chatroom.service.intf.ChatService;
import openbang.chatroom.service.vo.ChatGroup;
import openbang.chatroom.web.widget.ViewChatRoomList;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.RootPanel;

/**
 * 
 * 显示聊天室列表
 * 
 * @author aibozeng
 *
 */

public class ChatRoomList implements EntryPoint {
	final ViewChatRoomList viewChatRoomList = new ViewChatRoomList();
	
	@Override
	public void onModuleLoad() {		
		RootPanel.get("listchatroom_div").add(viewChatRoomList);
		ChatService.Util.getInstance().getAllGroup(new AsyncCallback<List<ChatGroup>>(){
			public void onFailure(Throwable caught) {
				Window.alert(caught.getMessage());
			}
			public void onSuccess(List<ChatGroup> result) {
				if(result==null){
					return;
				}
				viewChatRoomList.initData(result);
				//隐藏进度条
				RootPanel.get("loading").setVisible(false);
			}
		});
	}
	
}
